package org.springboot.base.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author ZJL
 * @DateTime 2019年2月11日 下午9:06:12
 * 
 **/
@Controller
@RequestMapping("/demo")
public class DemoController {
	
	//获取配置信息
	@Value("${com.web.yltd}")
	private String yltd;
	
	@Autowired
	private RedisTemplate<String, String> redisTemplate;

	@RequestMapping("/toDemo")
	public String toDemo(ModelMap map) {
		map.addAttribute("hostName","http://www.baidu.com");
		System.out.println("com.web.yltd=="+yltd);
		System.out.println("Redis set userName =中国-China-110");
		redisTemplate.opsForValue().set("userName", "中国-China-110");
		System.out.println("Redis get userName ="+redisTemplate.opsForValue().get("userName"));
		return "demo";
	}
	
	public String getYltd() {
		return yltd;
	}

	public void setYltd(String yltd) {
		this.yltd = yltd;
	}
	
}
